/*
 * InfoStringParse.java
 * 
 * Analyses the information and sorts it so that other methods can read it.
 * 
 * Author: Andres Ruiz
 * License: see License.txt
 */
public class InfoStringParse
{
	private String EleInfo;
	
	public InfoStringParse(String elementInfo)
	{
		EleInfo = elementInfo;
	}
	
	public InfoStringParse(String elementInfo, boolean debug)//debuging constructor
	{
		EleInfo = elementInfo;
		System.out.println(getName());
		System.out.println(getSymbol());
		System.out.println(getAtomicNumber());
		System.out.println(getAtomicMass());
	}
	
	public String getName()// Gets the element's name
	{
		int IndexOfName = EleInfo.indexOf("Element Name: ") + 14;
		int IndexOfEleSym = EleInfo.indexOf("Element Symbol");
		String valueToRet = EleInfo.substring(IndexOfName, IndexOfEleSym).trim();
		return (valueToRet);
	}
	
	public String getSymbol()// Gets the element's symbol
	{
		int IndexOfName = EleInfo.indexOf("Element Symbol: ") + 16;
		int IndexOfEleSym = EleInfo.indexOf("Atomic Number");
		String valueToRet = EleInfo.substring(IndexOfName, IndexOfEleSym).trim();
		return (valueToRet);
	}
	
	public int getAtomicNumber()// Gets the element's Atomic Number
	{
		int IndexOfName = EleInfo.indexOf("Atomic Number: ") + 15;
		int IndexOfEleSym = EleInfo.indexOf("Atomic Mass");
		String valueToRet = EleInfo.substring(IndexOfName, IndexOfEleSym).trim();
		return Integer.parseInt(valueToRet);
	}
	
	public double getAtomicMass()// Gets the element's Atomic Mass
	{
		int IndexOfName = EleInfo.indexOf("Atomic Mass: ") + 13;
		int IndexOfEleSym = EleInfo.indexOf("g/mol");
		String valueToRet = EleInfo.substring(IndexOfName, IndexOfEleSym).trim();
		return Double.parseDouble(valueToRet);
	}
}
